<template>
  <el-form :model="editForm" :rules="rules" label-width="135px" ref="editFormRef">
    <div class="bg-white my-[10px]">
      <BaseHead>基本信息</BaseHead>
      <div class="p-[10px]">
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="批准号" prop="authorizeCode">
              <el-input v-model="editForm.authorizeCode" placeholder="批准号" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目名称" prop="name">
              <el-input v-model="editForm.name" placeholder="项目名称" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="12" prop="code">
            <el-form-item label="项目编号">
              {{ editForm.code ? editForm.code : "审核通过后生成" }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="负责人" prop="chargerName">
              <el-autocomplete
                v-model="editForm.chargerName"
                :fetch-suggestions="queryChargerPerosn"
                clearable
                placeholder="请输入检索关键词"
                value-key="name"
                highlight-first-item
                @select="selectChargerPerosn"
                @blur="chargerPerosnBlur"
                v-if="editForm.chargerType != 3"
                :disabled="verifyRoleType.isKyry()"
              >
                <template #default="{ item }">
                  <span>{{ item.name }}</span>
                  <span class="mx-[10px]">{{ item.account }}</span>
                  <span>{{ item.unitName }}</span>
                </template>
              </el-autocomplete>
              <el-input v-else v-model="editForm.chargerName" placeholder="负责人" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="负责人类型" prop="chargerType">
              <CommonRadio
                :isFetch="false"
                :dataList="memberTypeList"
                v-model="editForm.chargerType"
                valueKey="code"
                @change="chargerTypeChange"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属单位" prop="unitId">
              <CommonTreeSelect
                placeholder="所属单位"
                v-model="editForm.unitId"
                valueKey="codeColumn"
                labelKey="valueColumn"
                :isFetch="false"
                :dataList="unitList"
                :disabled="editForm.chargerType != 3"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目分类" prop="projectTypeCode">
              <CommonTreeSelect
                :isFetch="false"
                :dataList="projectTypeList"
                placeholder="项目分类"
                v-model="editForm.projectTypeCode"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目级别" prop="projectLevelId">
              <CommonSelect
                placeholder="项目级别"
                :isFetch="false"
                :dataList="projectLevelList"
                v-model="editForm.projectLevelId"
                valueKey="code"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目来源单位" prop="projectTier">
              <el-input v-model="editForm.projectTier" placeholder="项目来源单位" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目状态" prop="projectStatusId">
              <CommonRadio
                :isFetch="false"
                :dataList="projectStatusList"
                v-model="editForm.projectStatusId"
                valueKey="code"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="立项日期" prop="authorizeDate">
              <el-date-picker
                v-model="editForm.authorizeDate"
                type="date"
                clearable
                placeholder="立项日期"
                value-format="YYYY-MM-DD"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开始日期" prop="beginDate">
              <el-date-picker
                v-model="editForm.beginDate"
                type="date"
                clearable
                placeholder="开始日期"
                value-format="YYYY-MM-DD"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划结项日期" prop="planEndDate">
              <el-date-picker
                v-model="editForm.planEndDate"
                type="date"
                clearable
                value-format="YYYY-MM-DD"
                placeholder="计划结项日期"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结项日期" prop="actualEndDate">
              <el-date-picker
                v-model="editForm.actualEndDate"
                type="date"
                clearable
                disabled
                value-format="YYYY-MM-DD"
                placeholder="结项日期"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目总经费" prop="feeAuthorize">
              <el-input
                v-model="editForm.feeAuthorize"
                placeholder="项目总经费"
                clearable
                @input="fomateNumber(editForm, 'feeAuthorize', $event)"
                @blur="feeAuthorizeBlur"
              >
                <template #append>万元</template>
              </el-input></el-form-item
            >
          </el-col>
          <el-col :span="12">
            <el-form-item label="拨款金额" prop="selfProvideFee">
              <el-input
                v-model="editForm.selfProvideFee"
                placeholder="拨款金额"
                clearable
                @input="fomateNumber(editForm, 'selfProvideFee', $event)"
              >
                <template #append>万元</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="学校资助经费" prop="attachFee">
              <el-input
                v-model="editForm.attachFee"
                placeholder="学校资助经费"
                clearable
                @input="fomateNumber(editForm, 'attachFee', $event)"
              >
                <template #append>万元</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="外拨经费" prop="outFee">
              <el-input
                v-model="editForm.outFee"
                placeholder="外拨经费"
                clearable
                @input="fomateNumber(editForm, 'outFee', $event)"
                @blur="outFeeBlur"
              >
                <template #append>万元</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="成果形式" prop="productMode">
              <el-input v-model="editForm.productMode" placeholder="成果形式" clearable> </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
    </div>
    <div class="bg-white">
      <BaseHead>教育部统计信息</BaseHead>
      <div class="p-[10px]">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="统计归属" prop="subjectClassId">
              <CommonRadio
                :isFetch="false"
                :dataList="tjgsList"
                v-model="editForm.subjectClassId"
                valueKey="code"
                @change="tjgschange"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="一级学科" prop="subjectId">
              <CommonSelect
                placeholder="一级学科"
                :isFetch="false"
                :dataList="subjectList.value"
                v-model="editForm.subjectId"
                labelKey="label"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="社会经济服务目标" prop="societyTarget">
              <CommonTreeSelect
                :isFetch="false"
                :dataList="jjfwmbList"
                placeholder="社会经济服务目标"
                v-model="editForm.societyTarget"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目来源" prop="projectSourceId">
              <CommonSelect
                placeholder="项目来源"
                :isFetch="false"
                :dataList="projectSourceList.value"
                v-model="editForm.projectSourceId"
                labelKey="label"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="研究类别" prop="researchClassId">
              <CommonSelect
                placeholder="研究类别"
                :isFetch="false"
                :dataList="researchTypeList.value"
                v-model="editForm.researchClassId"
                labelKey="label"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="国民经济行业" prop="gmjjhy">
              <CommonTreeSelect
                :isFetch="false"
                :dataList="gmjjhyList"
                placeholder="国民经济行业"
                v-model="editForm.gmjjhy"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </div>
    </div>
    <div class="bg-white mt-[10px]">
      <BaseHead>详细信息</BaseHead>
      <div class="p-[10px]">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="课题类型" prop="levelType">
              <CommonRadio
                :isFetch="false"
                :dataList="ktTypeList"
                v-model="editForm.levelType"
                valueKey="code"
                @change="ktTypeChange"
              />
            </el-form-item>
          </el-col>
          <!-- 项目：1 课题：2 子课题：3 -->
          <!-- 选择课题时才显示 -->
          <template v-if="editForm.levelType == 2">
            <el-col :span="24">
              <el-form-item label="课题性质" prop="subjectNature">
                <CommonRadio
                  :isFetch="false"
                  :dataList="ktxzList"
                  v-model="editForm.subjectNature"
                  valueKey="code"
                  @change="ktXzChange"
                />
              </el-form-item>
            </el-col>
            <!-- 不是独立课题时时显示 -->
            <template v-if="editForm.subjectNature != 'independent'">
              <el-col :span="24">
                <el-form-item label="依托项目名称" prop="upItemName">
                  <el-input
                    v-model="editForm.upItemName"
                    placeholder="依托项目名称"
                    clearable
                    v-if="editForm.subjectNature == 'otherSchool'"
                  />
                  <el-autocomplete
                    v-model="editForm.upItemName"
                    :fetch-suggestions="queryProjectList"
                    clearable
                    placeholder="请输入检索关键词"
                    value-key="proName"
                    highlight-first-item
                    @select="selectProject"
                    @blur="selectProjectBlur"
                    v-else
                  >
                    <template #default="{ item }">
                      <span>{{ item.proName }}</span>
                      <span class="ml-[50px]">{{ item.chargerName }}</span>
                    </template>
                  </el-autocomplete>
                </el-form-item>
                <el-form-item label="依托项目负责人" prop="relyingProjectLeader">
                  <el-input
                    v-model="editForm.relyingProjectLeader"
                    placeholder="依托项目负责人"
                    clearable
                  >
                  </el-input>
                </el-form-item>
                <el-form-item
                  label="依托项目单位名称"
                  prop="relyingProjectUnitName"
                  v-if="editForm.subjectNature == 'otherSchool'"
                >
                  <el-input
                    v-model="editForm.relyingProjectUnitName"
                    placeholder="依托项目单位名称"
                    clearable
                  >
                  </el-input>
                </el-form-item>
              </el-col>
            </template>
          </template>
          <!-- 选择子课题时显示 -->
          <template v-if="editForm.levelType == 3">
            <el-col :span="24">
              <el-form-item label="牵头人单位" prop="leadUnitName">
                <el-input v-model="editForm.leadUnitName" placeholder="牵头人单位" clearable />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="牵头人单位负责人" prop="leadUnitLeader">
                <el-input
                  v-model="editForm.leadUnitLeader"
                  placeholder="牵头人单位负责人"
                  clearable
              /></el-form-item>
            </el-col>
          </template>
          <el-col :span="24">
            <el-form-item label="备注" prop="note">
              <el-input
                v-model="editForm.note"
                placeholder="备注"
                type="textarea"
                show-word-limit
                maxlength="500"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </div>
    </div>
  </el-form>
</template>

<script setup>
import BaseHead from "@/views/project/components/BaseHead.vue";
import CommonRadio from "@/views/project/components/CommonRadio.vue";
import CommonSelect from "@/views/project/components/CommonSelect.vue";
import CommonTreeSelect from "@/views/project/components/CommonTreeSelect.vue";
import useCommonFetch from "@/hooks/useCommonFetch";
import { getPersonList } from "@/api/project/common";
import { assignObj } from "@/utils/main";
import { editRecords, baseDetail, getList } from "@/api/project/zx/lxxm";
import { verifyRoleType, fomateNumber } from "@/utils/main";
import useUserStore from "@/store/modules/user";
import { ElMessage } from "element-plus";
const userStore = useUserStore();
const memberTypeList = inject("memberTypeList");
const unitList = inject("unitList");
const projectTypeList = inject("projectTypeList");
const projectLevelList = inject("projectLevelList");
const projectStatusList = inject("projectStatusList");
const tjgsList = inject("tjgsList");
const jjfwmbList = inject("jjfwmbList");
const gmjjhyList = inject("gmjjhyList");
const ktTypeList = inject("ktTypeList");
const ktxzList = inject("ktxzList");
const isAuditor = inject("isAuditor");
const taskId = inject("taskId");
const checkStatus = inject("checkStatus");
let subjectList = ref([]); //一级学科下拉数据
let researchTypeList = ref([]); //研究类别下拉数据
let projectSourceList = ref([]); //项目来源下拉数据
const editFormRef = ref();
const operateId = ref(null);
const baseInfoData = ref({});
const lastFeeAuthorize = ref(0); //未修改之前的总经费
const lastOutFee = ref(0);
const editForm = reactive({
  proClass: "zXProject",
  authorizeCode: "", //批准号
  name: "", //项目名称
  code: "", //项目编号
  chargerName: "", //负责人
  chargerCode: "", //负责人ID
  chargerEmail: "", //负责人邮箱
  chargerPhone: "", //负责人电话
  chargerType: "", //负责人类型
  unitId: "", //所属单位
  projectTypeCode: "", //项目分类
  projectLevelId: "", //项目级别
  projectTier: "", //项目来源单位
  projectStatusId: "", //项目状态
  authorizeDate: "", //立项日期
  beginDate: "", //开始日期
  planEndDate: "", //计划结项日期
  actualEndDate: "", //结项日期
  feeAuthorize: "", //项目总经费
  selfProvideFee: "", //拨款金额
  attachFee: "", //学校资助经费
  outFee: "", //外拨经费
  productMode: "", //成果形式
  subjectClassId: "", //统计归属
  subjectId: "", //一级学科
  societyTarget: "", //社会经济服务目标
  projectSourceId: "", //项目来源
  researchClassId: "", //研究类别
  gmjjhy: "", //国民经济行业
  levelType: "", //课题类型
  subjectNature: "", //课题性质
  upItemName: "", //依托项目名称
  upItemId: "", //依托项目id
  relyingProjectLeader: "", //依托项目负责人
  relyingProjectUnitName: "", //依托项目单位名称
  leadUnitName: "", //牵头人单位
  leadUnitLeader: "", //牵头单位负责人
  note: "", //备注
});
//验证总经费
const validateFeeAuthorize = (rule, value, callback) => {
  if (editForm.outFee) {
    if (parseFloat(value) <= parseFloat(editForm.outFee)) {
      callback(new Error("项目总经费必须大于外拨经费"));
    } else {
      callback();
    }
  } else {
    callback();
  }
};
//验证外拨经费
const validateOutFee = (rule, value, callback) => {
  if (value) {
    if (editForm.feeAuthorize) {
      if (parseFloat(value) >= parseFloat(editForm.feeAuthorize)) {
        callback(new Error("外拨经费必须小于项目总经费"));
      } else {
        callback();
      }
    } else {
      callback();
    }
  } else {
    callback();
  }
};
//验证立项日期
const validateAuthorizeDate = (rule, value, callback) => {
  if (editForm.planEndDate) {
    if (new Date(value).getTime() >= new Date(editForm.planEndDate).getTime()) {
      callback(new Error("立项日期必须早于计划结项日期"));
    } else {
      callback();
    }
  } else {
    callback();
  }
};
//验证计划结项日期
const validatePlanEndDate = (rule, value, callback) => {
  if (editForm.authorizeDate || editForm.beginDate) {
    if (editForm.authorizeDate && editForm.beginDate) {
      if (
        new Date(value).getTime() <= new Date(editForm.authorizeDate).getTime() &&
        new Date(value).getTime() <= new Date(editForm.beginDate).getTime()
      ) {
        callback(new Error("计划结项日期必须晚于立项日期、开始日期"));
      } else if (new Date(value).getTime() <= new Date(editForm.authorizeDate).getTime()) {
        callback(new Error("计划结项日期必须晚于立项日期"));
      } else if (new Date(value).getTime() <= new Date(editForm.beginDate).getTime()) {
        callback(new Error("计划结项日期必须晚于开始日期"));
      } else {
        callback();
      }
    } else if (editForm.authorizeDate) {
      if (new Date(value).getTime() <= new Date(editForm.authorizeDate).getTime()) {
        callback(new Error("计划结项日期必须晚于立项日期"));
      } else {
        callback();
      }
    } else if (editForm.beginDate) {
      if (new Date(value).getTime() <= new Date(editForm.beginDate).getTime()) {
        callback(new Error("计划结项日期必须晚于开始日期"));
      } else {
        callback();
      }
    }
  } else {
    callback();
  }
};
//验证开始日期
const validateBeginDate = (rule, value, callback) => {
  if (value) {
    if (editForm.planEndDate) {
      if (new Date(value).getTime() >= new Date(editForm.planEndDate).getTime()) {
        callback(new Error("开始日期必须早于计划结项日期"));
      } else {
        callback();
      }
    } else {
      callback();
    }
  } else {
    callback();
  }
};
const rules = {
  name: [
    {
      required: true,
      message: "项目名称必填",
    },
  ],
  chargerName: [
    {
      required: true,
      message: "负责人必填",
    },
  ],
  projectTypeCode: [
    {
      required: true,
      message: "项目分类必填",
    },
  ],
  projectLevelId: [
    {
      required: true,
      message: "项目级别必填",
    },
  ],
  authorizeDate: [
    {
      required: true,
      message: "立项日期必填",
    },
    { validator: validateAuthorizeDate, trigger: "blur" },
  ],
  beginDate: [{ validator: validateBeginDate, trigger: "blur" }],
  planEndDate: [
    {
      required: true,
      message: "计划结项日期必填",
    },
    { validator: validatePlanEndDate, trigger: "blur" },
  ],
  feeAuthorize: [
    {
      required: true,
      message: "项目总经费必填",
    },
    { validator: validateFeeAuthorize, trigger: "blur" },
  ],
  outFee: [{ validator: validateOutFee, trigger: "blur" }],
  subjectClassId: [
    {
      required: true,
      message: "统计归属必填",
    },
  ],
  subjectId: [
    {
      required: true,
      message: "一级学科必填",
    },
  ],
  societyTarget: [
    {
      required: true,
      message: "社会经济服务目标必填",
    },
  ],
  projectSourceId: [
    {
      required: true,
      message: "项目来源必填",
    },
  ],
  researchClassId: [
    {
      required: true,
      message: "研究类别必填",
    },
  ],
  gmjjhy: [
    {
      required: true,
      message: "国民经济行业必填",
    },
  ],
  levelType: [
    {
      required: true,
      message: "课题类型必填",
    },
  ],
  leadUnitName: [
    {
      required: true,
      message: "牵头人单位必填",
    },
  ],
  leadUnitLeader: [
    {
      required: true,
      message: "牵头单位负责人必填",
    },
  ],
  upItemName: [
    {
      required: true,
      message: "依托项目名称必填",
    },
  ],
  relyingProjectLeader: [
    {
      required: true,
      message: "依托项目负责人必填",
    },
  ],
  relyingProjectUnitName: [
    {
      required: true,
      message: "牵依托项目单位名称必填",
    },
  ],
};
const emit = defineEmits(["save-success", "save-ok"]);
//获取详情
const getBaseInfoData = async () => {
  try {
    const res = await baseDetail(operateId.value);
    baseInfoData.value = res.data;
    lastFeeAuthorize.value = res.data.feeAuthorize;
    lastOutFee.value = res.data.outFee;
  } catch (error) {
    console.log(error);
  }
};
// 新增
const add = () => {
  operateId.value = null;
  if (verifyRoleType.isKyry()) {
    editForm.chargerName = userStore.nickName;
    editForm.chargerCode = userStore.userRealId;
    editForm.chargerPhone = userStore.phonenumber;
    editForm.chargerEmail = userStore.email;
    editForm.unitId = userStore.deptId;
  }
};
// 编辑
const edit = async (id) => {
  operateId.value = id;
  nextTick(async () => {
    await getBaseInfoData();
    //表单表格赋值
    assignObj(editForm, baseInfoData.value);
    //重新给subjectNature赋值 避免始终选择第一个课题性质
    nextTick(() => {
      editForm.subjectNature = baseInfoData.value.subjectNature;
    });
  });
};
const save = async (submitType) => {
  try {
    await editFormRef.value?.validate(async (valid) => {
      if (valid) {
        let params = {
          ...editForm,
          submitType,
          isAuditor: isAuditor.value,
          taskId: taskId.value,
          checkstatus: checkStatus.value,
        };
        if (operateId.value) {
          params.id = operateId.value;
        }
        const res = await editRecords(params);
        if (res.code === 200) {
          emit("save-success", res.data);
        }
      }
    });
  } catch (error) {
    console.log(error);
  } finally {
    emit("save-ok");
  }
};
defineExpose({ add, edit, save });
//项目总经费输入框失去焦点
const feeAuthorizeBlur = () => {
  if (operateId.value && lastFeeAuthorize.value != editForm.feeAuthorize) {
    ElMessage({
      message: `批准经费已经更改，请修改预算明细！`,
      type: "warning",
    });
  }
};
//外拨经费输入焦点
const outFeeBlur = () => {
  if (operateId.value && lastOutFee.value != editForm.outFee) {
    ElMessage({
      message: `外拨经费已经更改，请修改合作单位！`,
      type: "warning",
    });
  }
};
//根据姓名查询负责人
const queryChargerPerosn = async (queryString, cb) => {
  if (queryString.trim() == "") {
    return;
  }
  //输入时清空chargerCode结合blur事件，控制负责人必须是选择的下拉框的值
  editForm.chargerCode = "";
  const params = {
    name: queryString,
  };
  try {
    const res = await getPersonList(params);
    cb(res.data);
  } catch (error) {
    console.log(error);
  }
};
//选择负责人
const selectChargerPerosn = (val) => {
  editForm.chargerCode = val.id;
  editForm.chargerEmail = val.email;
  editForm.chargerPhone = val.mobile;
  editForm.unitId = val.unitId;
};
//清空负责人字段的值
const resetChargerPerosn = () => {
  editForm.chargerCode = "";
  editForm.chargerName = "";
  editForm.chargerEmail = "";
  editForm.chargerPhone = "";
  editForm.unitId = "";
};
//选择负责人框失去焦点
const chargerPerosnBlur = () => {
  if (!editForm.chargerCode) {
    resetChargerPerosn();
  }
};
//负责人类型改变
const chargerTypeChange = (val) => {
  if (verifyRoleType.isKyry()) {
    //校内和学生类型默认取当前登录人为负责人
    if (val == 1 || val == 2) {
      editForm.chargerName = userStore.nickName;
      editForm.chargerCode = userStore.userRealId;
      editForm.chargerPhone = userStore.phonenumber;
      editForm.chargerEmail = userStore.email;
      editForm.unitId = userStore.deptId;
    } else {
      resetChargerPerosn();
    }
  } else {
    //选择校外时或者从校外选择校内或学生时 清空负责人的值
    if (val == 3 || (val != 3 && editForm.chargerCode == "")) {
      resetChargerPerosn();
    }
  }
};
//查询纵向项目课题类型为项目的数据
const queryProjectList = async (queryString, cb) => {
  if (queryString.trim() == "") {
    return;
  }
  editForm.upItemId = "";
  const params = {
    name: queryString,
    pageNo: 1,
    pageSize: 1000,
    proClass: "zXProject",
    levelId: 1, //课题类型为项目
  };
  try {
    const res = await getList(params);
    cb(res.rows);
  } catch (error) {
    console.log(error);
  }
};
//选择某个项目
const selectProject = (val) => {
  editForm.upItemId = val.id;
  editForm.relyingProjectLeader = val.chargerName;
  editForm.relyingProjectUnitName = val.unitName;
};
//清空依托项目信息
const resetRelyingProject = () => {
  editForm.upItemName = "";
  editForm.upItemId = "";
  editForm.relyingProjectLeader = "";
  editForm.relyingProjectUnitName = "";
};
//选择项目失去焦点
const selectProjectBlur = () => {
  if (!editForm.upItemId) {
    resetRelyingProject();
  }
};
//课题类型改变
const ktTypeChange = () => {
  //清空牵头人单位、牵头人单位负责人的值
  editForm.leadUnitName = "";
  editForm.leadUnitLeader = "";
  //如果课题类型不是课题，清空课题性质
  if (editForm.levelType != 2) {
    editForm.subjectNature = "";
  }
  resetRelyingProject();
};
//课题性质改变
const ktXzChange = () => {
  resetRelyingProject();
};
//监听统计归属的值改变
watch(
  () => editForm.subjectClassId,
  (newVal) => {
    subjectList.value = useCommonFetch("一级学科", newVal);
    researchTypeList.value = useCommonFetch("研究类别", newVal);
    projectSourceList.value = useCommonFetch("项目来源", newVal);
  }
);
//手动改变统计归属的值 清空一级学科、项目来源、研究类别的值
const tjgschange = () => {
  editForm.subjectId = "";
  editForm.projectSourceId = "";
  editForm.researchClassId = "";
};
</script>

<style scoped lang="scss"></style>
